package com.fhz.shop.ui.login.data;

import androidx.lifecycle.LiveData;

import com.fhz.shop.api.ServiceApi;
import com.fhz.shop.callback.ApiResponse;
import com.fhz.shop.entity.HUser;


import java.io.IOException;

import javax.inject.Inject;

/**
 * Class that handles authentication w/ login credentials and retrieves user information.
 */
public class LoginDataSource {
    @Inject
    ServiceApi mServiceApi;

    @Inject
    public LoginDataSource() {
    }

    public LiveData<ApiResponse<HUser>> login(String username, String password) {

//        try {

           return mServiceApi.login(username,password);

            // TODO: handle loggedInUser authentication
//            HUser fakeUser =
//                    new HUser();
//            return new Result.Success<>(fakeUser);
//        } catch (Exception e) {
//            return new Result.Error(new IOException("Error logging in", e));
//        }
    }

    public void logout() {
        // TODO: revoke authentication
    }
}